﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TimeTravel.Controllers;
using TimeTravel.Controllers.Castle;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web;
using Castle.Windsor;

namespace TimeTravel.Controllers
{
    public class ChannelControllerFactory : WindsorControllerFactory
    {
        public ChannelControllerFactory(IWindsorContainer container) : base(container)
        {
            
        }
        protected override IController GetControllerInstance(RequestContext context, Type controllerType)
        {
            if (controllerType == null || String.IsNullOrEmpty(controllerType.FullName))
            {
                throw new HttpException(404, string.Format("The controller for path '{0}' could not be found or it does not implement IController.", context.HttpContext.Request.Path));
            }
            if (controllerType.FullName.Equals("TimeTravel.Controllers.HomeController"))
            {
                return new HomeController();
            }
            if (controllerType.FullName.Equals("TimeTravel.Controllers.PartialViewController"))
            {
                return new PartialViewController();
            }
            if (controllerType.FullName.Equals("TimeTravel.Controllers.SystemController"))
            {
                return new SystemController();
            }
            if (controllerType.FullName.Equals("TimeTravel.Controllers.ResourceController"))
            {
                return new ResourceController();
            }
            if (controllerType.FullName.Equals("TimeTravel.Controllers.ErrorController"))
            {
                return new ErrorController();
            }
            if (controllerType.FullName.Equals("TimeTravel.Controllers.ManageController"))
            {
                return new ManageController();
            }
            return base.GetControllerInstance(context, controllerType);
        }
    }
}
